package com.dzf.controller;

import com.dzf.entity.Hot;
import com.dzf.entity.LargeFile;
import com.dzf.entity.RespJson;
import com.dzf.service.HotService;
import com.dzf.service.LargeFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.UUID;

@CrossOrigin
@RestController
@RequestMapping("/api/adm/hot")
public class AdmHotController {
    @Autowired
    HotService hotService;
    @Autowired
    LargeFileService largeFileService;

    @RequestMapping("/findAll")
    public RespJson findAll(){
        return RespJson.pack(200,"OK",hotService.findAll());
    }

    @RequestMapping("/addHot")
    public RespJson addHot(Hot hot, @RequestParam("pic") MultipartFile pic)
    {
        return RespJson.pack(200,"添加成功", hotService.addHot(hot,pic));
    }

    @RequestMapping("/delete/{id}")
    public RespJson delete(@PathVariable("id")int id)
    {
        hotService.delete(id);
        return RespJson.pack(200,"删除成功",hotService.findAll());
    }
}
